/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.mach.service.impl;

import jodd.util.StringUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.mach.entity.DrawingInfoNode;
import org.springblade.mach.vo.DrawingInfoNodeVO;
import org.springblade.mach.mapper.DrawingInfoNodeMapper;
import org.springblade.mach.service.IDrawingInfoNodeService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;

/**
 *  服务实现类
 *
 * @author LY
 * @since 2021-03-05
 */
@Service
public class DrawingInfoNodeServiceImpl extends BaseServiceImpl<DrawingInfoNodeMapper, DrawingInfoNode> implements IDrawingInfoNodeService {

	@Override
	public IPage<DrawingInfoNodeVO> selectDrawingInfoNodePage(IPage<DrawingInfoNodeVO> page, DrawingInfoNodeVO drawingInfoNode) {
		return page.setRecords(baseMapper.selectDrawingInfoNodePage(page, drawingInfoNode));
	}

	@Override
	public DrawingInfoNode getDrawingBomNumByChildId(Long parentId, Long childId) {
		if (parentId == null) {
			throw new ServiceException("父节点主键不能为空!");
		}
		if (childId == null) {
			throw new ServiceException("子节点主键不能为空!");
		}
		return baseMapper.getDrawingBomNumByChildId(parentId, childId);
	}

	@Override
	public List<DrawingInfoNode> findDrawingNodeList(Long parentId) {
		if (parentId == null) {
			throw new ServiceException("参数不能为空!");
		}
		return baseMapper.findDrawingNodeList(parentId);
	}

	@Override
	public List<Long> findParentLevelIdList(String subDrawingNumber) {
		if (StringUtil.isEmpty(subDrawingNumber)) {
			throw new ServiceException("图纸编号不能为空!");
		}
		return baseMapper.findParentLevelIdList(subDrawingNumber);
	}


}
